package com.zhouyu.fileSync.FScommon.commonUtils;

import com.alibaba.fastjson.JSON;

/**
 * Created by zhouyu@lightinthebox.com on 2019/8/8
 **/
public class SerializeUtils {

    /**
     * 序列化
     *
     * @param o
     * @return
     */
    public static byte[] serialize(Object o) {
        return JSON.toJSONBytes(o);
    }

    /**
     * 反序列化
     *
     * @param bytesArray
     * @param clazz
     * @param <T>
     * @return
     */
    public static <T> T unserialize(byte[] bytesArray, Class<T> clazz) {
        return JSON.parseObject(bytesArray, clazz);
    }

}
